<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<script type="text/javascript">
	function submitBlog() {
		var content = $("#content").val();
		if(content==""){
			$("#contentTips").html("<font color='red'>请输入日志内容!</font>");
		}
		var subject=$("#subject").val();
		//var subjectTxt = subject.replace(/(<.*?>)/ig,'');
		if(subject==""){
			$("#subjectTips").html("<font color='red'>请输入标题!</font>");
		}if(content!=""&&subject!=""){
			$.ajax({
				type : "POST",
				url : "postBlog.htm",
				data : {
					'content' : content,
					'subject' : subject,
					'classname' : $("#classname ").val(),
					'password' : $("#blogPwd").val(),
					'visibility' : $("#visibility").val(),
					'isForward' : $("#isForward").attr("checked")
					
				},
				success : function() {
					$("#preImg").html("1111111111111111");
					$("#content").xheditor(false);
					$("#content_detail").load(
							"enterBlog.htm?&operationType=postSuccess");
					
				}
			});
		}
		
	}
	//初始化xheditor
	$(function() {
		$("#content").xheditor({
			tools : 'Removeformat,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Align,Emot,Img',
			skin : 'default',
			showBlocktag : false,//段落标签
			internalScript : false,
			internalStyle : false,
			width : 590,
			height : 368,
			fullscreen : false,
			forcePtag : true,
			upMultiple:1,
			html5Upload:false,
			upImgUrl : "xhUploadImage.htm",
			upImgExt:'jpg,jpeg,gif,png',
			onUpload:insertUpload//指定回调函数
		});
		$("#content").focus();
	});
	//编辑图片上传回调函数
	function insertUpload(msg){
		$("#preImg").html("图片预览：<img width='200' height='150' src='"+msg+"'/>")
		var _msg=msg.toString();
		$("#content").append(_msg);
	}
	//处理服务器返回到回调函数的字符串内容,格式是JSON的数据格式.
	function Substring(s){
		return s.substring(s.substring(0,s.lastIndexOf("/")).lastIndexOf("/"),s.length);
	}
	$(function(){
		$("#subject").focus(function(){
			$("#subjectTips").html("");
		});
	});
</script>

<div class="h_editBox">
	<table>
		<tr>
			<td width="59" class="h_edit_text" >标题:</td>
			<td width="679" ><input class="h_edit_title" type="text"
				id="subject" name="subject" />  <div id="subjectTips"></div>
			</td>
		</tr>
		<tr>
			<td class="h_edit_text">内容:</td>
			<td><textarea id="content" name="content" style="overflow: hidden;"></textarea><div id="contentTips"></div>
			</td>

		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>分类： <select id="classname">
					<c:forEach items="${cList}" var="classname">
						<option value="${classname.value }">${classname.label}</option>
					</c:forEach>
			</select> <%-- <a href="#">[分类管理]</a> --%>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>权限： <select id="visibility">
					<c:forEach items="${vList}" var="blogVisibility">
						<option value="${blogVisibility.value }">${blogVisibility.label}</option>
					</c:forEach>
			</select> <%-- <input id="isForward" type="checkbox" value="" />允许好友转帖</td> --%>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>
				<div class="h_button fl mr5" onclick="submitBlog();">
					<strong>发 表</strong>
				</div>
				<div class="h_button fl" onclick="blogInfo();">
					<strong>取 消</strong>
				</div></td>
		</tr>
	</table>
</div>
